<template>
    <view>
       
        <u-row  v-for="a in goodslist">
            <u-col v-for="b in a" span=4 @click="toxiangqing(b.id)">
                <u-image :radius="20" width="100%" height="120px" :src="'http://101.43.223.224:8765/image/getImageById?id='+b.imgId.split(',')[0]"></u-image>
                <view style="margin-top: 5px;">
                {{b.goodsName}}
                </view>
                <view>
                    ￥<text style="color: #EB0045;font-size: 20px;">{{b.startPrice}}</text>
                </view>
            </u-col>
         
            
        </u-row>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                goodslist:[[]],
                
            }
        },
        props:['list'],
        methods: {
            
        },
        methods:{
          toxiangqing(id){
              uni.navigateTo({
                  url:'/pages/paiMaiXiangQing/paiMaiXiangQing?id='+id
              })
          }  
        },
        mounted() {
            var imgs = this.list
            var index  = 0
            for(var a in imgs){
                if(!this.goodslist[index]){
                    this.goodslist[index]= []
                }
                this.goodslist[index].push(imgs[a])
                if((a+1)%3 == 0){
                    index += 1
                }
            }
            console.log(this.goodslist)
   
        },
        watch:{
            list(newvalue,oldvalue){
               var imgs = newvalue
               var index  = 0
               for(var a in imgs){
                   if(!this.goodslist[index]){
                       this.goodslist[index]= []
                   }
                   this.goodslist[index].push(imgs[a])
                   if((a+1)%3 == 0){
                       index += 1
                   }
               }
               console.log(this.goodslist)
            }
        }

    }
</script>

<style>

</style>
